package top.fzqblog.kotlinapp.util

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import org.jetbrains.anko.db.*
import org.w3c.dom.Text
import top.fzqblog.kotlinapp.app.KotlinApp
import top.fzqblog.kotlinapp.func.log
import top.fzqblog.kotlinapp.tables.InfoTable

/**
 * Created by 抽离 on 2017/11/21 0021.
 */
class AnkoDBHelper:ManagedSQLiteOpenHelper(KotlinApp.instance, dbName, null, version) {

    companion object {
        val dbName = "kotlinapp"
        val version = 1
        val instance by lazy{AnkoDBHelper()}
    }

    override fun onCreate(db: SQLiteDatabase?) {
        log("-------------ankoDbHelper-----------createDB--------------------------")
        db?.createTable(InfoTable.Table_Name, true,
                InfoTable.ID to  INTEGER + PRIMARY_KEY,
                InfoTable.key to TEXT + NOT_NULL,
                InfoTable.value to  TEXT + NOT_NULL
                )
    }

    override fun onUpgrade(dp: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
    }

}